// 获取名称
export function showNameByValue(val, arr) {
  if (val === undefined || val === null || val === '') {
    return ''
  }
  if (arr === undefined || arr === null || !Array.isArray(arr) || arr.length <= 0) {
    return val
  }
  var name = ''
  arr.forEach(item => {
    if (item.value === val) {
      name = item.name
      return
    }
  })
  return name
}

// 根据某个属性名称、属性值获取另一属性值
export function getPropValByPropNameVal(name, val, anotherName, arr) {
  if (!name || !val || !anotherName) {
    return null
  }
  if (!arr || !Array.isArray(arr)) {
    return null
  }
  for (let index = 0; index < arr.length; index++) {
    const ele = arr[index]
    if (ele[name] && ele[name] === val && ele[anotherName]) {
      return ele[anotherName]
    }
  }
  return null
}
